/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package dao;

import java.sql.PreparedStatement;
import java.sql.SQLException;
import model.Account;


/**
 *
 * @author adriano
 */
public class AccountDAO implements DAO{

    private final DataSource dataSource;

    public AccountDAO() {
        dataSource = new DataSource();
    }
    
    
    
    public void create(Object o) {
        try {

            String sql = "INSERT INTO account VALUES (null,?,?,?,?)";
            PreparedStatement ps = dataSource.getConnection().prepareStatement(sql);
            Account acccount = (Account) o;

            ps.setString(1, acccount.getTxtgrauDeConta());
            ps.setString(2,acccount.getGrau());
            ps.setString(3, acccount.getTxtDescricao());
            ps.setString(4,acccount.getLstStatus());
           
          

            int res = ps.executeUpdate();
            ps.close();
            if (res == 0) {
                System.err.println("CONTADAO.CREATE - Nenhuma conta criado !");

            }
        } catch (SQLException e) {
            System.err.println("CONTADAO.CREATE  - " + e.getMessage());

        }
    }

    public void delete(Object o) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    public void update(Object o) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    
    public Object read(Object o) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
    
    
     public void closeDAO() {
        dataSource.closeConnection();
    }
    
}
